package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduMessageModelParams.EduMessageModelParamsQueryVO;
import com.jwsoft.manager.common.vo.eduMessageModelParams.EduMessageModelParamsVO;
import com.jwsoft.manager.common.vo.eduSendMessageModel.EduSendMessageModelKeyVO;
import com.jwsoft.manager.common.vo.eduSendMessageModel.EduSendMessageModelQueryVO;
import com.jwsoft.manager.common.vo.eduSendMessageModel.EduSendMessageModelVO;
import com.jwsoft.manager.core.integration.EduSendMessageModelIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发送短信内容模板网关
 *
 * @author zjl
 * @since 2024-06-24
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "发送短信内容模板", description = "发送短信内容模板")
public class EduSendMessageModelController {

    @Autowired
    public EduSendMessageModelIntegration eduSendMessageModelIntegration;

    @Operation(summary = "发送短信内容模板分页查询",description = "发送短信内容模板分页查询")
    @PostMapping(value = "/eduSendMessageModel0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSendMessageModelVO>> getList(@RequestBody @Validated EduSendMessageModelQueryVO vo) {
        return AppResponse.successData(eduSendMessageModelIntegration.getList(vo));
    }

    @Operation(summary = "发送短信内容模板根据主键查询详情",description = "发送短信内容模板根据主键查询详情")
    @PostMapping(value = "/eduSendMessageModel0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSendMessageModelVO> getById(@RequestBody @Validated EduSendMessageModelKeyVO vo) {
        return AppResponse.successData(eduSendMessageModelIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "发送短信内容模板新增",description = "发送短信内容模板新增")
    @PostMapping(value = "/eduSendMessageModel0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSendMessageModelVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSendMessageModelVO vo) {
        return AppResponse.successData(eduSendMessageModelIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "发送短信内容模板修改",description = "发送短信内容模板修改")
    @PostMapping(value = "/eduSendMessageModel0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSendMessageModelVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSendMessageModelVO vo) {
        return AppResponse.successData(eduSendMessageModelIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "发送短信内容模板删除",description = "发送短信内容模板删除")
    @PostMapping(value = "/eduSendMessageModel0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSendMessageModelKeyVO vo) {
        eduSendMessageModelIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Operation(summary = "查询模板参数",description = "查询模板参数")
    @PostMapping(value = "/eduSendMessageModel0007", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduMessageModelParamsVO>> getModelParams(@RequestBody @Validated EduMessageModelParamsQueryVO vo) {
        return AppResponse.successData(eduSendMessageModelIntegration.getModelParams(vo));
    }
}
